package spring.example.cloud.service.impl;

import jakarta.annotation.Resource;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import spring.example.cloud.config.ChatMemoryConfig;
import spring.example.cloud.service.ChatMemoryService;

/**
 * @Auther:Liu
 * @Testname:ChatMemoryServiceImpl
 * @Date:2025/9/23 11:47
 */
@Service
@Slf4j
public class ChatMemoryServiceImpl implements ChatMemoryService {
    @Resource
    private ChatClient ollamaChatClient;

    @Override
    public Flux<String> getMessages(String userId, String question) {
        return ollamaChatClient.prompt()
                .advisors(advisors ->
                        advisors.param("chat_memory_conversation_id", userId))
                .user(question).stream().content();
    }
}
